package Generics_Reflect;

class Kontener<T> {
	private T t1, t2, t3;

	public Kontener(T t1, T t2, T t3) {
		this.t1 = t1;
		this.t2 = t2;
		this.t3 = t3;
	}

	public T get(int index) {
		T ret = null;
		switch (index) {
		case 1:
			ret = t1;
			break;
		case 2:
			ret = t2;
			break;
		case 3:
			ret = t3;
			break;
		}
		return ret;
	}

	public void set(T t, int index) {
		switch (index) {
		case 1:
			this.t1 = t;
			break;
		case 2:
			this.t2 = t;
			break;
		case 3:
			this.t3 = t;
			break;
		}
	}

	@Override
	public String toString() {
		return "Kontener [t1=" + t1 + ", t2=" + t2 + ", t3=" + t3 + "]";
	}
	

}

public class Cwiczenie2 {
	public static void main(String[] args) {
		Kontener<String> k1 = new Kontener<String>("Ala", "ma", "kota");
		System.out.println(k1);
		System.out.println(k1.get(1));
		k1.set("psa", 3);
		System.out.println(k1);
	}

}
